package com.zyh.homework.test1;

import java.io.Serial;
import java.io.Serializable;

/**
 * @Author zyh
 * @Date 2024/8/13 19:33
 * @Description
 */

public class Book implements Serializable {
    @Serial
    private static final long serialVersionUID = 7653691196320202109L;
    private String title;
    private String author;
    private Integer year;
    private Double prince;

    public Book() {
    }

    public Book(String title, String author, Integer year, Double prince) {
        this.title = title;
        this.author = author;
        this.year = year;
        this.prince = prince;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public Integer getYear() {
        return year;
    }

    public void setYear(Integer year) {
        this.year = year;
    }

    public Double getPrince() {
        return prince;
    }

    public void setPrince(Double prince) {
        this.prince = prince;
    }

    @Override
    public String toString() {
        return "Book{" +
                "title='" + title + '\'' +
                ", author='" + author + '\'' +
                ", year=" + year +
                ", prince=" + prince +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Book book = (Book) o;

        if (title != null ? !title.equals(book.title) : book.title != null) return false;
        if (author != null ? !author.equals(book.author) : book.author != null) return false;
        if (year != null ? !year.equals(book.year) : book.year != null) return false;
        return prince != null ? prince.equals(book.prince) : book.prince == null;
    }

    @Override
    public int hashCode() {
        int result = title != null ? title.hashCode() : 0;
        result = 31 * result + (author != null ? author.hashCode() : 0);
        result = 31 * result + (year != null ? year.hashCode() : 0);
        result = 31 * result + (prince != null ? prince.hashCode() : 0);
        return result;
    }
}
